package cn.jbit.service;

import cn.jbit.mapper.OrderMapper;
import cn.jbit.pojo.Order;
import cn.jbit.utils.Constants;
import cn.jbit.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 张在成
 */
@Service
@Slf4j
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderMapper orderDao;

    @Override
    public Order selectOrderByOrderId(Integer orderId){
        //判断订单号是否为空
        if (orderId==null){
            log.info("rest您的订单号为空");
            return null;
        }
        Order order=orderDao.selOrderByOrderId(orderId);
        //判断订单号多对应的订单是否存在
        if (order==null){
            log.info("rest您查找的订单不存在...");
            return null;
        }
        System.out.println("订单详情："+order);
        return order;
    }



    @Override
    public List<Order> getOrderList() {

        List<Order> orderList=orderDao.selOrderList();

        if (orderList==null){
            log.info("您要查找的订单信息不存在");
            return  null;
        }
        return  orderList;
    }




    @Override
    public List<Order> selOrderListByIds(List<Integer> list) {

        if (list==null){
            log.warn("rest您的订单id是空的");
        }

        List<Order> orderList=orderDao.selOrderInfoByIds(list);

        if (orderList==null){
            log.warn("rest您的订单信息是空的");
            return null;
        }
        return orderList;
    }
}
